; (function () {
    "use strict"
    onload = function () {
        //左上角有货更多
        const omore = document.querySelector(".more");
        const omoreMine = document.querySelector(".more-min");
        const aa = document.querySelectorAll(".more-min li a");
        omore.onmouseover = function () {
            omoreMine.style.display = "block";
            omoreMine.onmouseout = function () {
                omoreMine.style.display = "none";
            }
            omore.onmouseout = function () {
                omoreMine.style.display = "none";
            }
        }
        let aminz = ["集团官网", "男生潮流", "女生潮流", "新鲜好去处", "潮流嘉年华"];
        let aminy = ["YOHO!", "YOHO!BOYS", "YOHO!GIRLS", "Mars", "YO'HOOD"]
        for (let i = 0; i < aa.length; i++) {
            aa[i].index = i
            aa[i].onmouseover = function () {
                this.innerHTML = aminz[this.index];
                this.style.fontSize = "16px";
            }
            aa[i].onmouseout = function () {
                this.innerHTML = aminy[this.index];
                this.style.fontSize = "14px";
            }
        }
        //==============================
        //导航二级菜单
        let oFs = document.querySelector(".Fs")
        let ofs = document.querySelector(".fs")
        oFs.onmouseover = function () {
            ofs.style.display = "block";
            ofs.onmouseout = function () {
                ofs.style.display = "none";
            }
            oFs.onmouseout = function () {
                ofs.style.display = "none";
            }
        }
        let oXl = document.querySelector(".Xl")
        let oxl = document.querySelector(".xl")
        oXl.onmouseover = function () {
            oxl.style.display = "block";
            oxl.onmouseout = function () {
                oxl.style.display = "none";
            }
            oXl.onmouseout = function () {
                oxl.style.display = "none";
            }
        }
        let oBd = document.querySelector(".Bd")
        let obd = document.querySelector(".bd")
        oBd.onmouseover = function () {
            obd.style.display = "block";
            obd.onmouseout = function () {
                obd.style.display = "none";
            }
            oBd.onmouseout = function () {
                obd.style.display = "none";
            }
        }
        let oPs = document.querySelector(".Ps")
        let ops = document.querySelector(".ps")
        oPs.onmouseover = function () {
            ops.style.display = "block";
            ops.onmouseout = function () {
                ops.style.display = "none";
            }
            oPs.onmouseout = function () {
                ops.style.display = "none";
            }
        }
        //==============================
        //轮播图
        class Banner {
            constructor() {
                //获取元素
                this.oimgb = document.querySelector(".imgb")
                this.aimg = document.querySelectorAll(".imgb img");
                this.obtnl = document.querySelector(".btnl")
                this.obtnr = document.querySelector(".btnr")
                //设置默认索引为0
                this.index = 0;
                this.addEvent();
            }
            addEvent() {
                //添加事件
                const that = this
                //点击右键
                this.obtnr.onclick = function () {
                    that.clickr()
                }
                this.obtnl.onclick = function () {
                    that.clickl()
                }
                this.zidon()
            }
            clickr() {
                if (this.index === this.aimg.length - 1) {
                    this.oimgb.style.left = 0
                    this.index = 0;
                }
                this.index++;
                this.clickrRender()
            }
            clickrRender() {
                move(this.oimgb, {
                    left: -this.index * this.aimg[0].offsetWidth
                })
            }

            clickl() {
                if (this.index === 0) {
                    this.index = this.aimg.length - 1;
                    this.oimgb.style.left = (-this.index) * this.aimg[0].offsetWidth + "px";
                }
                this.index--;
                this.clicklRender()
            }
            clicklRender() {
                move(this.oimgb, {
                    left: -this.index * this.aimg[0].offsetWidth
                })
            }
            zidon() {
                this.t;
                clearInterval(this.t)
                this.t = setInterval(() => {
                    if (this.index === this.aimg.length - 1) {
                        this.oimgb.style.left = 0
                        this.index = 0;
                    }
                    this.index++;
                    move(this.oimgb, {
                        left: -this.index * this.aimg[0].offsetWidth
                    })
                }, 3000)
            }
        }
        new Banner()
        //=====================
        //返回顶栏
        let oback = document.querySelector("#back");
        oback.onclick = function () {
            clearInterval(t)
            var t = setInterval(function () {
                var n = 100;
                if (document.documentElement.scrollTop === 0) {
                    clearInterval(t)
                }
                document.documentElement.scrollTop
                    -= n--
            }, 30);
        }
        //==========================
        //楼层
        // const at = document.querySelectorAll(".lc1")
        // const aspan = document.querySelectorAll("#floor>span")
        // document.documentElement.scrollTop = 100
        // console.log(document.documentElement.scrollTop += 100)
        // for (let i = 0; i < aspan.length; i++) {
        //     aspan[i].index = i
        //     aspan[i].onclick = function () {
        //         let zt = document.documentElement.scrollTop;
        //         let xt = at[this.index].offsetTop - 50;
        //         clearInterval(o)
        //         var o = setInterval(() => {
        //             if (zt < xt) {
        //                 zt += 50
        //                 if (zt >= at[this.index].offsetTop - 50) {
        //                     zt = at[this.index].offsetTop - 50;
        //                     clearInterval(o)
        //                 }
        //             }
        //             if (zt > xt) {
        //                 zt -= 50 + "px"
        //                 if (zt <= at[this.index].offsetTop - 50) {
        //                     zt = at[this.index].offsetTop - 50;
        //                     clearInterval(o)
        //                 }
        //             }
        //             console.log(zt)
        //         }, 30);
        //     }
        // }
        //==============================
        //缓冲运动
        function move(ele, obj, callback) {
            clearInterval(ele.t);
            ele.t = setInterval(() => {
                let status = true;
                for (let attr in obj) {
                    let now = parseInt(getStyle(ele, attr))
                    let speed = (obj[attr] - now) / 10;
                    speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
                    if (now !== obj[attr]) {
                        status = false
                    }
                    ele.style[attr] = now + speed + "px"
                }
                if (status) {
                    clearInterval(ele.t)
                    callback && callback()
                }
            }, 30)
        }

        function getStyle(ele, attr) {
            return getComputedStyle ? getComputedStyle(ele)[attr] : ele.currentStyle[attr]
        }
    }
})();